home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Die Speccy' 97
/
Die Speccy' 97.iso
/
amiga_system
/
the_aminet
/
comm
/
bbs
/
maxsgames.lha
/
MaxGames
/
Drag.lha
/
drag.c
< prev
Wrap
C/C++ Source or Header
|
1991-03-15
|
15KB
|
463 lines
#if LATTICE
#include <proto/exec.h>
#else
#include <functions.h>
#endif
#include <exec/exec.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
long money;
short win;
short car1,car2,car3;
short odd1,odd2,odd3;
short bet;
long amount_bet;
char cars1[] = "\\_/~\\ ";
char car_1[] = "(O)~O>";
char cars2[] = "/|_|\\ [2]";
char car_2[] = "\\O==O}";
char cars3[] = "[\\/~\\_[3]";
char car_3[] = "\\O==o/";
char newcar[10];
char cont[10];
char text[80];
#define CAR if(doormsg->carrier==1) return;
#define DROP if(doormsg->carrier==1) end();
struct DoorMsg {
struct Message Door_Msg;
short command;
short data;
char string[80];
short carrier;
};
struct DoorMsg *doormsg,*garbage;
struct MsgPort *MyPort,*replyport;
extern void getsvar();
extern void sendmessage();
extern void hotkey();
extern void prompt();
extern void sprompt();
extern void showfile();
extern void end();
extern void cls();
struct Task *mytask; /* Pointer to this task so we can name it */
int err;
main(argc,argv)
int argc;
char *argv[];
{
char username[81],line_number;
char tmp[81],str[81];
char doorspath[80];
char rportname[10],cportname[12]; /* ReplyPort and Control Port names */
int num,numq,numa;
short answers[26][21];
int coun,coun2,inn,tota;
int polln;
int fd;
FILE *fp,*fopen();
float percent;
/* Pull out the line number from the argv field to find where we are */
line_number=argv[1][0];
mytask=FindTask(0L);
mytask->tc_Node.ln_Name = "Drag Race V0.90"; /* You'll probably want to
change the name to the
name of whatever your door
is! */
/* Create the Reply port, with the name based on the number...
Attempts at doing this with a simple "sprintf" failed, causing
the creation of garbled portnames. This works fine. Stick with
it. */
switch(line_number){
case '0': replyport=CreatePort("DoorReply0",0L); break;
case '1': replyport=CreatePort("DoorReply1",0L); break;
case '2': replyport=CreatePort("DoorReply2",0L); break;
case '3': replyport=CreatePort("DoorReply3",0L); break;
case '4': replyport=CreatePort("DoorReply4",0L); break;
case '5': replyport=CreatePort("DoorReply5",0L); break;
case '6': replyport=CreatePort("DoorReply6",0L); break;
case '7': replyport=CreatePort("DoorReply7",0L); break;
case '8': replyport=CreatePort("DoorReply8",0L); break;
case '9': replyport=CreatePort("DoorReply9",0L); break;
}
doormsg=(struct DoorMsg *)AllocMem((long)sizeof(*doormsg),MEMF_PUBLIC);
if(doormsg==0)
{
puts("Couldn't allocate DoorMsg!");
return;
}
doormsg->Door_Msg.mn_Node.ln_Type = NT_MESSAGE;
doormsg->Door_Msg.mn_ReplyPort = replyport;
doormsg->Door_Msg.mn_Length = (UWORD)sizeof(*doormsg);
/* Locate the correct DoorControl port based on the line number */
sprintf(cportname,"DoorControl%c",line_number);
MyPort=FindPort(cportname);
if(MyPort==0L)
{
puts("DoorControl port not located!");
FreeMem(doormsg,(long)sizeof(*doormsg));
return;
}
/* Now for the main program area - see below for explanations of
getsvar, sendmessage, and hotkey (as well as many more). */
sendmessage("************************************************",1);
sendmessage("* D R A G R A C I N G V 0.90 *",1);
sendmessage("* *",1);
sendmessage("* P A R A G O N V E R S I O N B Y *",1);
sendmessage("* *",1);
sendmessage("* D. Z A K I K A R A C H I W A L A *",1);
sendmessage("* *",1);
sendmessage("* O N M A R C H 1 5 1 9 9 1 *",1);
sendmessage("************************************************",1);
sendmessage("",1);
win = 50;
money = 50;
sendmessage("",1);
sendmessage("Current Team Car:",1);
sendmessage("_________________",1);
sendmessage("",1);
sendmessage(cars1,1);
sendmessage(car_1,1);
sendmessage("",1);
hotkey("Do you want to make a new car ?",newcar);
DROP;
if (toupper(newcar[0]) == 'Y')
{
sendmessage("",1);
sendmessage("Design your car (Max 6 Characters/Top & Bottom)");
sendmessage("",1);
sendmessage("",1);
sendmessage("Current Car Body Roof");
sendmessage("",1);
sendmessage(cars1,1);
prompt(">",cars1,7);
DROP;
strncpy(cars1,cars1,6);
sendmessage("",1);
sendmessage("Current Car Body Base");
sendmessage("",1);
sendmessage(car_1,1);
prompt(">",car_1,7);
DROP;
strncpy(cars1,car_1,6);
}
while (money > 0 && toupper(cont[0]) != 'N')
{
car1 = 0;
car2 = 0;
car3 = 0;
cls();
/* Number = rand() % range + 2 */
odd1 = rand() % 3 +2;odd2 = rand() % 3+2;odd3 = rand() % 3+2;
sendmessage("",1);
sendmessage("Pete Rose's Drag Race Pool",1);
sendmessage("-=-=-=-=-=-=-=-=-=-=-=-=-=",1);
sendmessage("Car | Odds |",1);
sendmessage("-------------------------------",1);
sendmessage("",1);
sprintf(text," %s[1] | %d:1 | (Your Race Team)",
cars1,odd1);
sendmessage(text,1);
sprintf(text," %s | |",car_1);
sendmessage(text,1);
sprintf(text," %s | %d:1 |",cars2,odd2);
sendmessage(text,1);
sprintf(text," %s | |",car_2);
sendmessage(text,1);
sprintf(text," %s | %d:1 |",cars3,odd3);
sendmessage(text,1);
sprintf(text," %s | |",car_3);
sendmessage(text,1);
sendmessage("-------------------------------",1);
sendmessage("",1);
sendmessage("",1);
sprintf(text,"Currently You Have ($%d) In Your Wallet",money);
sendmessage(text,1);
sendmessage("",1);
hotkey("What Race Team Do You Want To Bet On (1(Yours),2,3) ?",text);
DROP;
bet = atoi(text);
if (bet != 1 && bet != 2 && bet != 3)
bet = 1;
sendmessage("",1);
sendmessage("",1);
prompt("Enter Amount You Want To Bet (Minimum 1) $",text,6);
DROP;
amount_bet = atoi(text);
if ( amount_bet < 1 )
amount_bet = 1;
else if (amount_bet > money)
amount_bet = money;
cls();
while (car1<win || car2<win || car3<win)
{
sprintf(text,"\033[1;%dH ",car1);
sendmessage(text,0);
sprintf(text,"\033[2;%dH___",car1);
sendmessage(text,1);
sprintf(text,"\033[4;%dH ",car2);
sendmessage(text,0);
sprintf(text,"\033[5;%dH___",car2);
sendmessage(text,0);
sprintf(text,"\033[7;%dH ",car3);
sendmessage(text,0);
sprintf(text,"\033[8;%dH___",car3);
sendmessage(text,0);
car1 = car1 + rand() % 4;
car2 = car2 + rand() % 4;
car3 = car3 + rand() % 4;
sprintf(text,"\033[1;%dH%s[1]",car1,cars1);
sendmessage(text,0);
sprintf(text,"\033[2;%dH%s",car1,car_1);
sendmessage(text,0);
sprintf(text,"\033[4;%dH%s",car2,cars2);
sendmessage(text,0);
sprintf(text,"\033[5;%dH%s",car2,car_2);
sendmessage(text,0);
sprintf(text,"\033[7;%dH%s",car3,cars3);
sendmessage(text,0);
sprintf(text,"\033[8;%dH%s",car3,car_3);
sendmessage(text,0);
}
if (car1>=car2)
{
if (car1>=car3)
{
cls();
sendmessage("Car 1 Is First",1);
sendmessage("",1);
sendmessage("",1);
if (bet == 1)
{ sendmessage("You Win Big Time!!!!",1);
money = money + amount_bet*odd1;
}
else
{ sendmessage("You LOOSE BIG TIME!!!!",1);
money = money - amount_bet;
}
}
else
{
cls();
sendmessage("Car 3 Is First",1);
sendmessage("",1);
sendmessage("",1);
if (bet == 3)
{ sendmessage("You Win Big Time!!!!",1);
money = money + amount_bet*odd3;
}
else
{ sendmessage("You LOOSE BIG TIME!!!!",1);
money = money - amount_bet;
}
}
}
else if (car2 >= car3)
{
cls();
sendmessage("Car 2 Is First",1);
sendmessage("",1);
sendmessage("",1);
if (bet == 2)
{ sendmessage("You Win Big Time!!!!",1);
money = money + amount_bet*odd2;
}
else
{ sendmessage("You LOOSE BIG TIME!!!!",1);
money = money - amount_bet;
}
}
else
{
cls();
sendmessage("Car 3 Is First",1);
sendmessage("",1);
sendmessage("",1);
if (bet == 3)
{ sendmessage("You Win Big Time!!!!",1);
money = money + amount_bet*odd3;
}
else
{ sendmessage("You LOOSE BIG TIME!!!!",1);
money = money - amount_bet;
}
}
if (money > 0) {
hotkey("Would you like to continue (Y/N) ?",cont);
DROP;
}
}
end();
}
void cls()
{
int i;
for(i=1;i <= 24;i++)
sendmessage("",1);
}
void end()
{
doormsg->command = 20;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
FreeMem(doormsg,(long)sizeof(*doormsg));
DeletePort(replyport);
exit(0);
}
/*
* getsvar(typ,mstring) - Gets certain string variables from Paragon.
* "mstring" is a pointer to a string to dump the string into. "typ" tells
* it what you want: 1=Name, 2=Password, 3=Address, 4=City, 5=State
* 6=Postal code, 7=Door pathname, 8=Default BBS pathname.
*/
void getsvar(typ,mstring)
int typ;
char *mstring;
{
doormsg->data = typ;
doormsg->command = 14;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
strcpy(mstring,doormsg->string);
(void)GetMsg(replyport);
}
/*
* sendmessage(mstring,nl) - Sends a message to the local window and to
* the modem (if applicable). "mstring" is the output string you want to
* send, "nl" is and integer which is 1 if you want it to send the
* c/r+l/f combination, or 0 if not.
*/
void sendmessage(mstring,nl)
char mstring[];
int nl;
{
doormsg->data = nl;
doormsg->command = 1;
strcpy(doormsg->string,mstring);
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
}
/*
* hotkey(mstring,ostring) - outputs the string "mstring" and waits
* for one key which it will place in element [0] of "ostring".
* "mstring" may be a null string, in which case it will only wait for
* the key, and not output any prompt.
*/
void hotkey(mstring,ostring)
char mstring[];
char *ostring;
{
strcpy(doormsg->string,mstring);
doormsg->command = 8;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
strcpy(ostring,doormsg->string);
}
/*
* prompt(mstring,ostring,len) - outputs the string "mstring" and inputs
* a string which is placed in ostring. 'len' is the maximum number of
* characters which will be accepted.
*/
void prompt(mstring,ostring,len)
char mstring[];
char *ostring;
int len;
{
strcpy(doormsg->string,mstring);
doormsg->data=len;
doormsg->command = 6;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
strcpy(ostring,doormsg->string);
}
/* sprompt is the same as prompt, except it will accept stacked commands
* (with the '/' key) and will send back any stacked command which is
* currently in the command buffer instead of waiting for input from the
* user. It will even accept stacked commands which bridged over from the
* BBS.
*/
void sprompt(mstring,ostring,len)
char mstring[];
char *ostring;
int len;
{
strcpy(doormsg->string,mstring);
doormsg->data=len;
doormsg->command = 7;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
strcpy(ostring,doormsg->string);
}
/* showfile(mstring) shows the text file which mstring is the path to.
It handles ^C aborting, and ^S/^Q pausing. */
void showfile(mstring)
char mstring[];
{
strcpy(doormsg->string,mstring);
doormsg->command = 10;
PutMsg(MyPort,(struct Message *)doormsg);
(void)WaitPort(replyport);
(void)GetMsg(replyport);
}